import type { RouteRecordRaw } from 'vue-router'
import DefaultLayout from '@/layouts/Default.vue'

// 菜单路由
const menuRoutes: Array<RouteRecordRaw> = [
    {
        path: '/dashboard',
        name: 'dashboard',
        redirect: '/dashboard/index',
        component: DefaultLayout,
        meta: {
            title: '首页',
            icon: 'HomeFilled',
            isShowMenu: true
        },
        children: [
            {
                path: 'index',
                name: 'dashboardIndex',
                component: () => import('../views/dashboard/Dashboard.vue')
            }
        ]
    },

    {
        path: '/banner',
        name: 'banner',
        redirect: '/banner/index',
        component: DefaultLayout,
        meta: {
            title: '广告管理',
            icon: 'PictureFilled',
            isShowMenu: true
        },
        children: [
            {
                path: 'index',
                name: 'bannerIndex',
                meta: {
                    title: '广告列表'
                },
                component: () => import('../views/banner/Banner.vue')
            }
        ]
    },
    {
        path: '/category',
        name: 'category',
        redirect: '/category/index',
        component: DefaultLayout,
        meta: {
            title: '分类管理',
            icon: 'Grid',
            isShowMenu: true
        },
        children: [
            {
                path: 'index',
                name: 'categoryIndex',
                meta: {
                    title: '分类列表'
                },
                component: () => import('../views/category/Category.vue')
            },
            {
                path: 'ohter',
                name: 'categoryOhter',
                meta: {
                    title: '其他分类'
                },
                component: () => import('../views/category/Category.vue')
            }
        ]
    },
    {
        path: '/user',
        name: 'user',
        redirect: '/user/index',
        component: DefaultLayout,
        meta: {
            title: '用户管理',
            icon: 'UserFilled',
            isShowMenu: true
        },
        children: [
            {
                path: 'index',
                name: 'userIndex',
                meta: {
                    title: '用户列表'
                },
                component: () => import('../views/user/User.vue')
            },
            {
                path: 'indexs',
                name: 'userIndexs',
                meta: {
                    title: '用户设置'
                },
                component: () => import('../views/user/User.vue')
            }
        ]
    },
    {
        path: '/setting',
        name: 'setting',
        redirect: '/setting/index',
        component: DefaultLayout,
        meta: {
            title: '系统设置',
            icon: 'Setting',
            isShowMenu: true
        },
        children: [
            {
                path: 'index',
                name: 'settingIndex',
                component: () => import('../views/system/setting/Setting.vue')
            }
        ]
    }
]
// 基础路由
const baseRoutes: Array<RouteRecordRaw> = [
    {
        path: '/',
        redirect: '/dashboard/index'
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../views/login/Login.vue')
    },
    {
        path: '/profile',
        redirect: '/profile/index',
        component: DefaultLayout,
        meta: {
            title: '个人资料',
            icon: 'HomeFilled'
        },
        children: [
            {
                path: 'index',
                name: 'profile',
                component: () => import('../views/profile/Profile.vue')
            }
        ]
    }
]
const staticRoutes: Array<RouteRecordRaw> = getStaticRoutes()

function getStaticRoutes() {
    if (import.meta.env.VITE_ROUTE_MODE === 'dynamic') {
        return baseRoutes
    }
    return baseRoutes.concat(menuRoutes)
}

export default staticRoutes
